package com.jungle.system.config;

import com.jungle.common.config.properties.SshSftpProperties;
import com.jungle.system.config.properties.AliOssProperties;
import com.jungle.system.utils.oss.AliOssUtil;
import com.jungle.system.utils.oss.FileImportUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Slf4j
public class OssConfiguration {

    @Bean
    @ConditionalOnMissingBean //没有该Bean时才创建
    public AliOssUtil aliyunOssBean(AliOssProperties ossProperties) {
        log.info("开始创建阿里云Oss文件上传工具类对象");
        return new AliOssUtil(
                ossProperties.getEndpoint(),
                ossProperties.getAccessKeyId(),
                ossProperties.getAccessKeySecret(),
                ossProperties.getBucketName());
    }
    @Bean
    @ConditionalOnMissingBean //没有该Bean时才创建
    public FileImportUtil fileImportBean(SshSftpProperties properties) {
        return new FileImportUtil(properties);
    }

}
